﻿using System;
using CoreLib;
using System.Threading;

namespace CoreLib.Tests
{
    public partial class LogThreadTests
    {
        public class LogWriterForTest : ILogWriter
        {
            public int WriteCallCount = 0;
            public Log Log = null;

            public void Write(Log log)
            {
                WriteCallCount++;
                Log = log;
            }
        }

        public class ManualResetLogWriter : ILogWriter
        {
            public int WriteCallCount = 0;
            public Log Log = null;
            public readonly ManualResetEvent ResetEvent = new ManualResetEvent(false);

            public void Write(Log log)
            {
                WriteCallCount++;
                Log = log;
                ResetEvent.WaitOne();
                WriteCallCount--;
            }
        }

        public class ExceptionRaiseLogWriter : ILogWriter
        {
            public bool IsWriting = false;
            public void Write(Log log)
            {
                IsWriting = true;
                throw new ArgumentException();
            }
        }
    }
}
